package com.dj.ms.session;

import com.dj.common.DeJiSerializable;
import com.dj.common.lang.utils.HashUtil;
import lombok.*;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

/**
 * <br>
 * <p>session user object</p>
 *
 * <br>
 *
 * @author ZJG
 * @version 1.0
 * @date 2021/8/4 上午10:05
 */
@Setter
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Principal extends DeJiSerializable {
    private static final long serialVersionUID = -8725564168187260059L;

    /**
     * 用户编号
     */
    private String userId;

    /**
     * 用户名称
     */
    private String userName;

    /**
     * 商户ID
     */
    private String merchantId;

    /**
     * 商户名称
     */
    private String merchantName;

    /**
     * 店铺ID
     */
    private String storeId;

    /**
     * 店铺名称
     */
    private String storeName;

    /**
     * 登录地址
     */
    private String ip;

    private String phone;
    /**
     * 当前业务单元
     */
    private String bizUnit;
    /**
     * 当前系统通道
     */
    private String domainChannel;

    /** Gateway JWT userData */
    private String companyId;
    private String companyName;
    private String departmentId;
    private String departmentName;


    private String appType;
    private String browser;
    private String browserVersion;
    private String device;
    private String deviceType;
    private String os;
    private String osVersion;
    private String renderEngine;
    private String renderEngineVersion;
    /**
     * 客户端来源-关联 ClientSourceEnum
     */
    private String clientSource;

    public String fingerprint() {
        return HashUtil.sha1(StringUtils.join(new String[]{
                this.getUserId(),
                this.getMerchantId(),
                this.getStoreId(),
                this.getIp()
        }, "-"));
    }

}
